#include <iostream>
using namespace std;

class Persion
{
private:
    std::string name;
    int age;

public:
    auto getName() { return name; }
    auto getAge() { return age; }
    void setName(std::string name) { this->name = name; }
    void setAge(int age) { this->age = age; }

    // 构造函数
    Persion(string name, int age)
    {
        this->name = name;
        this->age = age;
    };

    // 析构函数
    ~Persion()
    {
        cout << "Persion " << name << " is dead." << endl;
    };

    virtual void makeSound();
};

class Student : public Persion
{
private:
    int id;

public:
    Student(string name, int age, int id) : Persion(name, age)
    {
        this->id = id;
    }

    auto getId() { return id; }

    void print()
    {
        cout << "Name: " << getName() << endl;
        cout << "Age: " << getAge() << endl;
        cout << "Id: " << getId() << endl;
    }

    virtual void makeSound()
    {
        cout << "student" << endl;
    }
};

class Teacher : public Persion
{
public:
    virtual void makeSound()
    {
        cout << "teacher" << endl;
    }

    Teacher(string name, int age) : Persion(name, age)
    {
    }
};

void test()
{
    Student stu("李四", 22, 20231001);
    stu.print();
    Teacher tea("teacher", 25);

    Persion *p1 = &stu;
    Persion *p2 = &tea;
    p1->makeSound();
    p2->makeSound();
}